import axios from '@/utils/request'

//流程部署
export const addFlowAsync = (params) => {
  return axios({
    method: 'POST',
    headers: { 'Content-Type': 'multipart/form-data' },
    data: params,
    url: '/lanlu/flowDefinition/deployFlow',
  })
}


//查询流程图表数据
export const getFlowDataListAysnc = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/flowDefinition/list?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}

//查看 xml
export const getFlowChartXMLAsync = (params) => {
  const { id: procDefId } = params
  return axios.get(`/lanlu/flowDefinition/flowXML?procDefId=${procDefId}`)
}
//查看 流程图
export const getFlowChartAsync = (params) => {
  const { id: procDefId } = params
  return axios.get(`/lanlu/flowDefinition/flowImg?procDefId=${procDefId}`)

}


//流程图状态修改
export const updateFlowStateAsync = (params) => {
  const { id: definitionId } = params
  return axios.get(`/lanlu/flowDefinition/updateState?definitionId=${definitionId}`)
}

//删除流程图
export const deleteFlowAsync = (params) => {
  const { deployId } = params
  return axios.delete(`/lanlu/flowDefinition/deleteFlow/${deployId}`)
}


//流程图设计， 获取所有表单标识 
export const getAllFormKeyAsync = () => {
  return axios.get('/lanlu/form/queryFinishForm')
}

//流程图设计  获取候选人或指定人员
export const getAllUserAsync = () => {
  return axios.get('/app/rest/editor-users?filter=')
}

//流程图设计  获取候选人或指定人员
export const getAllGroupAsync = () => {
  return axios.get('/app/rest/editor-groups?filter=')
}

//表单设计 创建表单
export const createNewFormAsync = (params) => {
  return axios.post('/app/rest/models', { ...params, "modelType": 2 })
}

//表单设计 保存表单
export const saveFormDataAsync = (id, params) => {
  return axios.put(`/app/rest/form-models/${id}`, params)
}

//表单设计 表单部署
export const deployFormAysnc = (params) => {
  return axios.post(`/lanlu/form/deployForm`, params)
}

//表单管理  查询表单数据
export const getFormListDataAsync = (params) => {
  const { currPage, pageSize, key } = params
  return axios.get(`/lanlu/form/list?currPage=${currPage}&pageSize=${pageSize}&key=${key}`)
}

//表单管理 表单删除
export const deleteFormAsync = (params) => {
  const { modelKey } = params
  return axios.delete(`lanlu/form/delForm/${modelKey}`)
}